<template>
  <div>
    <button @click="comName = 'MyLeft'">显示Left</button>
    <button @click="comName = 'MyRight'">显示Right</button>

    <!-- 使用 component 标签，可以动态的加载组件 -->
    <!-- <component :is="组件名"></component> -->
    <!-- 通过 给 keep-alive 加 include属性，来指定缓存哪些组件 -->
    <!-- 坑点：如果需要缓存多个组件，多个组件用逗号分割，绝对不能加空格 -->
    <component :is="comName"></component>
    <keep-alive> </keep-alive>
  </div>
</template>

<script>
// This starter template is using Vue 3 <script setup> SFCs
// Check out https://vuejs.org/api/sfc-script-setup.html#script-setup

import MyLeft from "@/components/MyLeft.vue";
import MyRight from "@/components/MyRight.vue";
export default {
  components: { MyLeft, MyRight },
  data() {
    return {
      comName: "MyLeft",
    };
  },

  created() {},
};
</script>

<style scoped>
.logo {
  height: 6em;
  padding: 1.5em;
  will-change: filter;
}
.logo:hover {
  filter: drop-shadow(0 0 2em #646cffaa);
}
.logo.vue:hover {
  filter: drop-shadow(0 0 2em #42b883aa);
}
</style>
